<?php
namespace m\controllers;

use Yii;
use yii\db\Query;
use common\models\Category;
use common\models\Product;
use common\models\ProductCategory;
use common\models\ProductGallery;
use common\models\Post;
use common\models\Brand;
use common\models\Banner;
use common\models\Order;
use yii\helpers\ArrayHelper;

/**
 * Category controller
 */
class CategoryController extends MController
{

    public function actionIndex(){
		
        $category_1=Category::find()
                ->where(['level'=>1,'parent_id'=>0,'is_show'=>1])
                ->select('name,id')
                //->limit(3)
                ->orderby('sort_number,id')
                ->asArray()
                ->all();

        $cate = Yii::$app->request->get('cate')?intval(Yii::$app->request->get('cate')):72;

        $category_2=Category::find()
                ->where(['level'=>2,'parent_id'=>$cate,'is_show'=>1])
                ->select('name,id')
                ->orderby('sort_number,id')
                ->asArray()
                ->all();
        //修改页面标题
        Yii::$app->view->params['page']['page_title'] = '分类 - ' . $this->w_config['website_name'];
	return $this->render('index',[
		'category_1' => $category_1,
		'category_2' => $category_2,
		'cate' => $cate,
	]);
    }

}

?>